<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>{$goods['number']}[{$goods['name']}]物资流水-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	.folder span{ display: inline-block; margin: 0 40px 0 1px; }
	.w280{ width: 280px; }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">物资库 > 物资流水 > {$goods['name']}</div>
	</div>
	<div id="content">
		<div class="filter clearfix">
			<div class="filter-item w280 left" style="border: none">
				<div class="filter-title">流水类型</div>
				<ul class="filter-order">
					<li <if condition="$types eq -10">class="current"</if>>
						<a href="__APP__/Administration/material_change/id/{$id}/types/-10/syb/{$syb}/start/{$start}/end/{$end}">全部</a>
					</li>
					<li <if condition="$types eq 1">class="current"</if>>
						<a href="__APP__/Administration/material_change/id/{$id}/types/1/syb/{$syb}/start/{$start}/end/{$end}">入库</a>
					</li>
					<li <if condition="$types eq 2">class="current"</if>>
						<a href="__APP__/Administration/material_change/id/{$id}/types/2/syb/{$syb}/start/{$start}/end/{$end}">出库</a>
					</li>
				</ul>
			</div>
			<div class="filter-item w280 left" style="border: none">
				<div class="filter-title">事业部</div>
				<ul class="filter-order">
					<li <if condition="$syb eq -10">class="current"</if>>
						<a href="__APP__/Administration/material_change/id/{$id}/types/{$types}/syb/-10/start/{$start}/end/{$end}">全部</a>
					</li>
					<li <if condition="$syb eq 目的地">class="current"</if>>
						<a href="__APP__/Administration/material_change/id/{$id}/types/{$types}/syb/目的地/start/{$start}/end/{$end}">目的地</a>
					</li>
					<li <if condition="$syb eq 旅发">class="current"</if>>
						<a href="__APP__/Administration/material_change/id/{$id}/types/{$types}/syb/旅发/start/{$start}/end/{$end}">旅发</a>
					</li>
					<li <if condition="$syb eq 旅投">class="current"</if>>
						<a href="__APP__/Administration/material_change/id/{$id}/types/{$types}/syb/旅投/start/{$start}/end/{$end}">旅投</a>
					</li>
					<li <if condition="$syb eq 景翼">class="current"</if>>
						<a href="__APP__/Administration/material_change/id/{$id}/types/{$types}/syb/景翼/start/{$start}/end/{$end}">景翼</a>
					</li>
				</ul>
			</div>
			<div class="filter-item w280 left" style="border: none">
				<div class="filter-title">日期筛选：</div>
				<div>
					<input name="start" value="{$start}" type="text" class="form-control Wdate required-text w100" onclick="WdatePicker()" readonly autocomplete="off">
					-
					<input name="end" value="{$end}" type="text" class="form-control Wdate required-text w100" onclick="WdatePicker()" readonly autocomplete="off">
					<span class='error-item'>开始日期必须小于结束日期</span>
					<button class="btn btndate" type="button">搜索</button>
				</div>
			</div>
		</div>
		<div class="table-scrollx">
			<table class="table table-bordered table-hover">
				<tr class="table-header fixed-table-header">
					<td width="">物资名称</td>
					<td width="">事业部</td>
					<td width="">流水类型</td>
					<td width="">数量</td>
					<td width="">单价(元)</td>
					<td width="">金额(元)</td>
					<td width="">操作人(日期)</td>
					<td width="">领用人</td>
					<td width="">用途</td>
					<td width="">管理</td>
				</tr>
				<if condition="$result eq NULL">
				<tr><td class="Text_c" colspan="9">暂无相关数据</td></tr>
				</if>
				<foreach name="result" item="vo">
					<tr>
						<td>{$goods['name']}</td>
						<td>{$vo['business_unit']}</td>
						<td><if condition="$vo['types'] eq 1"><span class="blue">入库(来源:{$vo['manufacturer']})</span><else/><span class="green">出库</span></if></td>
						<td>{$vo['nums']}</td>
						<td>{$vo['prices']+0}</td>
						<td>{$vo['sum']+0}</td>
						<td>{$vo['add_user']}({$vo['add_date']|substr=0,10})</td>
						<td>{$vo['user_name']}</td>
						<td>{$vo['purpose']}</td>
						<td>
							<if condition="$vo['audit'] eq 1">
								<a href="javascript:;" mid="{$vo['id']}" types="{$vo['types']}" business_unit="{$vo['business_unit']}" manufacturer="{$vo['manufacturer']}" nums="{$vo['nums']}" prices="{$vo['prices']+0}" user="{$vo['user']}" purpose="{$vo['purpose']}" sy="{$sy}" data-toggle="tooltip" data-placement="left" title="" class="edit mr5" data-original-title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
								<a href="javascript:;" mid="{$vo['id']}" action="delete" data-toggle="tooltip" data-placement="left" title="" class="delete" data-original-title="删除"><i class="glyphicon glyphicon-trash"></i></a>
							</if>
						</td>
					</tr>
				</foreach>
			</table>
		</div>
		<div class="pages">{$page}</div>
	</div>
</div>
<!--弹框-->
<div class="modal fade" id="in-modal">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4>入库</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<form class="in_form1" action="__APP__/Administration/material_add" method="post" enctype="multipart/form-data">
			<input type="hidden" name="action" value="edit">
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="74"><strong><span class="asterisk">*</span>事业部</strong></td>
						<td>
							<span class="checkbox-item in_radio">
								<label class="radio-inline"><input type="radio" name="business_unit" value="目的地" autocomplete="off">目的地</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="旅投" autocomplete="off">旅投</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="旅发" autocomplete="off">旅发</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="景翼" autocomplete="off">景翼</label>
								<span class="error-item">必填项</span>
							</span>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>来源</strong></td>
						<td>
							<input type="text" name="manufacturer" class="form-control required-text w150" autocomplete="off">
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>数量</strong></td>
						<td>
							<input type="text" name="nums1" class="form-control required-text w150" autocomplete="off">
							<span class="error-item">必填项</span>
							<span class="error-item">必须是大于0的整数</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>单价(元)</strong></td>
						<td>
							<input type="text" name="prices" class="form-control required-text w150" autocomplete="off">
							<span class="error-item">必填项</span>
							<span class="error-item">必须是大于0且可保留两位小数的数字</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<p class="Text_c1" style="color: #a94442;"></p>
				<button type="button" class="btn btn-affirm1">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
			</form>
		</div>
	</div>
</div>
<!--弹框-->
<div class="modal fade" id="out-modal">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4>出库</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<form class="in_form2" action="__APP__/Administration/material_add" method="post" enctype="multipart/form-data">
			<input type="hidden" name="action" value="edit">
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="74"><strong><span class="asterisk">*</span>事业部</strong></td>
						<td>
							<span class="checkbox-item out_radio">
								<label class="radio-inline"><input type="radio" name="business_unit" value="目的地" autocomplete="off">目的地</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="旅投" autocomplete="off">旅投</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="旅发" autocomplete="off">旅发</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="景翼" autocomplete="off">景翼</label>
								<span class="error-item">必填项</span>
							</span>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>数量</strong></td>
						<td>
							<input type="text" name="nums" class="form-control required-text w150" autocomplete="off">
							<span class="error-item">必填项</span>
							<span class="error-item">必须是大于0的整数</span>
							<span class="input-prompt ml10" style="color:#999"><i class="glyphicon glyphicon-exclamation-sign mr5"></i>库存剩余数<em></em></span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>单价(元)</strong></td>
						<td>
							<input type="text" name="pricess" class="form-control required-text w150" autocomplete="off">
							<span class="error-item">必填项</span>
							<span class="error-item">必须是大于0且可保留两位小数的数字</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>领用人</strong></td>
						<td>
							<select name="user" class="form-control required-selted w150" autocomplete="off">
								<option value="-10">请选择</option>
								<foreach name="user" item="uo">
								<option value="{$uo['id']}">{$uo['username']}</option>
								</foreach>
							</select>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>用途</strong></td>
						<td>
							<input type="text" name="purpose" class="form-control required-text w300" autocomplete="off">
							<span class="error-item">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<p class="Text_c" style="color: #a94442;"></p>
				<button type="button" class="btn btn-affirm2">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
			</form>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	//弹框
	$('.edit').click(function(){
		var types = $(this).attr('types');
		if(types == 1){
			var unit = $(this).attr('business_unit'),
				manufacturer = $(this).attr('manufacturer'),
				nums = $(this).attr('nums'),
				prices = $(this).attr('prices'),
				mid = $(this).attr('mid');
			$('#in-modal label').each(function(){
				if($(this).find('input').val()==unit){
					$(this).find('input').prop("checked",true);
				}
			})
			$('#in-modal').find("[name='nums1']").val(nums);
			$('#in-modal').find("[name='prices']").val(prices);
			$('#in-modal').find("[name='manufacturer']").val(manufacturer);
			$('#in-modal').modal();
			$('#in-modal').find('.btn-affirm1').attr('mid',mid)
		}else{
			var unit = $(this).attr('business_unit'),
				nums = $(this).attr('nums'),
				prices = $(this).attr('prices'),
				purpose = $(this).attr('purpose'),
				mid = $(this).attr('mid'),
				user = $(this).attr('user');
				sy = $(this).attr('sy');
			$('#out-modal label').each(function(){
				if($(this).find('input').val()==unit){
					$(this).find('input').prop("checked",true);
				}
			})
			$('.input-prompt em').html(sy);
			$('#out-modal').find("[name='nums']").val(nums);
			$('#out-modal').find("[name='pricess']").val(prices);
			$('#out-modal').find("[name='purpose']").val(purpose);
			$('#out-modal').find("[name='user']").find('option').each(function(){
				var val = $(this).val();
				if(val==user){
					$(this).attr("selected",true);
				}
			})
			$('#out-modal').find("[name='user']").select2();
			$('#out-modal').modal();
			$('#out-modal').find('.btn-affirm2').attr('mid',mid)
		}
	})
	//日期筛选
	$(".btndate").click(function(){
		var start = $("[name=start]").val(),
			end = $("[name=end]").val();
		if(Date.parse(end)>=Date.parse(start)){
			window.location.href = "__APP__/Administration/material_change/id/{$id}/types/{$types}/syb/{$syb}/start/"+start+"/end/"+end;
		}else{
			$(this).nextAll(".error-item").show();
		}
	});
	//取消错误提示
	$(".Wdate").on("focus",function(){
		$(this).nextAll(".error-item").hide();
	});
	//删除
	$(".delete").ajaxModal({"title_text":"确认提示框","body_text":"您确定要删除吗？","url":"__APP__/Administration/appliance_list_ajax","data":{"id":"mid","action":"action"}});
	//提交
	$('.btn-affirm1').click(function(){
		var tag = true;
		$('#in-modal .required-text').each(function(){
			var val = $(this).val();
			if(val==''){
				$(this).next('.error-item').show();
				tag = false;
			}
		})
		if($('.in_radio').find('input:checked').length<1){
			$('.in_radio').find(".error-item").show();
			tag = false;
		}
		var size = $("[name='nums1']").val();
		if(!/^\+?[1-9]\d*$/.test(size) && size!=""){
			$("[name='nums1']").nextAll(".error-item").eq(1).show();
			tag = false;
		}
		var money = $("[name='prices']").val();
		if(!/^(?!0$|0\.00|0\d+$)([1-9]?\d+(\.\d{1,2})?)$/.test(money) && money!=""){
			$("[name='prices']").nextAll(".error-item").eq(1).show();
			tag = false;
		}
		if(tag){
			var mid = $(this).attr('mid'),
				modal = $("#in-modal");
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:$('.in_form1').serialize()+"&id="+mid,
				url:"__APP__/Administration/appliance_list_ajax",
				success:function(data){
					if(data.status==1){
						modal.hide();
						success_pop(data.status,data.msg);
					}else{
						$('.Text_c1').html(data.msg);
					}
				}
			})
		}
	})
	$('.btn-affirm2').click(function(){
		var tag = true;
		$('#out-modal .required-text').each(function(){
			var val = $(this).val();
			if(val==''){
				$(this).next('.error-item').show();
				tag = false;
			}
		})
		if($('#out-modal select').val()==-10){
			$('#out-modal select').nextAll('.error-item').show();
			tag = false;
		}
		if($('.out_radio').find('input:checked').length<1){
			$('.out_radio').find(".error-item").show();
			tag = false;
		}
		var size = $("[name='nums']").val();
		if(!/^\+?[1-9]\d*$/.test(size) && size!=""){
			$("[name='nums']").nextAll(".error-item").eq(1).show();
			tag = false;
		}
		var money = $("[name='pricess']").val();
		if(!/^(?!0$|0\.00|0\d+$)([1-9]?\d+(\.\d{1,2})?)$/.test(money) && money!=""){
			$("[name='pricess']").nextAll(".error-item").eq(1).show();
			tag = false;
		}
		if(tag){
			var mid = $(this).attr('mid'),
				modal = $("#out-modal");
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:$('.in_form2').serialize()+"&id="+mid,
				url:"__APP__/Administration/appliance_list_ajax",
				success:function(data){
					if(data.status==1){
						modal.hide();
						success_pop(data.status,data.msg);
					}else{
						$('.Text_c').html(data.msg);
					}
				}
			})
		}
	})
	$('.required-text').focus(function(){
		$(this).nextAll('.error-item').hide();
	})
	$('label').click(function(){
		$(this).parent().find(".error-item").hide();
	})
	$('#out-modal select').change(function(){
		$(this).nextAll('.error-item').hide();
	})
});
</script>
</body>
</html>